package org.ocean.online.sys;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.apache.wicket.protocol.http.servlet.ServletWebRequest;

public class SimpleDispatchPage extends DispatchPage{
	private static final long serialVersionUID = -683815865162203557L;

	protected boolean preRender() {
		if(!"true".equalsIgnoreCase(OnlineConfig.getProperty("initd"))){
			this.setResponsePage(new SimpleInitPage());
			return false;
		}
		return true;
	}

	protected String getFullPath() {
		
		String fullPath ="";
		HttpServletRequest request = ((ServletWebRequest) getRequest()).getContainerRequest();
		String path = request.getServletPath();
		System.out.println(request.getPathInfo());
		if(path.startsWith("/"+OnlineConfig.getProperty("appName"))){
			String welcom = OnlineConfig.getProperty("welcome-file");
			path = welcom;
		}
		fullPath = request.getRealPath("/")+File.separator+"web-inf"+File.separator+path;
		return fullPath;
	}
}
